package com.swm.util;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.swm.mapper.StockJsonDataMapper;
import com.swm.pojo.Stock_Day_Data;
import com.swm.pojo.Stock_Json_Data;
import org.apache.ibatis.session.SqlSession;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 师文明
 * @data 2024/12/23 下午3:11
 **/
public class getStockDayData5011 {

    //0-20
    public static double sumz020;
    public static double sumf020;
    public static double sum020;
    public static int num0020;
    public static int numu020;
    public static int numd020;
    public static int ban020 = 0;
    public static double sum2020;
    public static int numu2020;
    public static int numd2020;
    public static int ban0220 = 0;

    private static ArrayList<String> dateList020 = new ArrayList<String>();
    //20-50
    public static double sumz2050;
    public static double sumf2050;
    public static double sum2050;
    public static double sum22050;
    public static double sum32050;

    public static int num02050;
    public static int numu2050;
    public static int numd2050;
    public static int numu22050;
    public static int numd22050;
    public static int numu32050;
    public static int numd32050;
    public static int ban2050 = 0;
    private static ArrayList<String> dateList2050 = new ArrayList<String>();
    //50-100
    public static double sumz50100;
    public static double sumf50100;
    public static double sum50100;
    public static double sum250100;
    public static double sum350100;

    public static int num050100;
    public static int numu50100;
    public static int numd50100;
    public static int numu250100;
    public static int numd250100;
    public static int numu350100;
    public static int numd350100;

    public static int ban50100 = 0;
    private static ArrayList<String> dateList50100 = new ArrayList<String>();
    //100-200
    public static double sumz100200;
    public static double sumf100200;
    public static double sum100200;
    public static double sum2100200;
    public static double sum3100200;

    public static int num0100200;
    public static int numu100200;
    public static int numd100200;
    public static int numu2100200;
    public static int numd2100200;
    public static int numu3100200;
    public static int numd3100200;

    public static int ban100200 = 0;
    private static ArrayList<String> dateList100200 = new ArrayList<String>();
    //200-370
    public static double sumz200370;
    public static double sumf200370;
    public static double sum200370;
    public static double sum2200370;
    public static double sum3200370;

    public static int num0200370;
    public static int numu200370;
    public static int numd200370;
    public static int numu2200370;
    public static int numd2200370;
    public static int numu3200370;
    public static int numd3200370;
    public static int ban200370 = 0;
    private static ArrayList<String> dateList200370 = new ArrayList<String>();

    public static DecimalFormat df = new DecimalFormat("#0.000");

    static SqlSession sqlSession = SqlSessionUtil.openSession();
    static StockJsonDataMapper stockJsonDataMapper = sqlSession.getMapper(StockJsonDataMapper.class);


    public static void main(String[] args) throws Exception {
        List<Stock_Json_Data> stockJsonDatalist = stockJsonDataMapper.selectStockJsonData();
        System.out.println(stockJsonDatalist.size());
        if(stockJsonDatalist.size()>0){
            for (Stock_Json_Data stockJsonData : stockJsonDatalist) {
                try {
                    getData(stockJsonData);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            Thread.sleep(50000);

            double v020 = 0;
            double vz020 = 0;
            double vf020 = 0;

            double v2020 = 0;
            System.out.println("120天内低位蛟龙出海");
            System.out.println("------------------------");
            if (num0020 != 0 && sum020 != 0) {
                v020 = sum020 / num0020;
                vz020= sumz020 / numu020;
                vf020= sumf020 / numd020;
            }
            if (num0020 != 0 && sum2020 != 0) {
                v2020 = sum32050 / sum2020;
            }
            System.out.println("0-20");
            System.out.println(("一天后涨的次数：" + numu020 + "  跌的次数：" + numd020 + "  上涨概率： " + df.format((double) numu020 * 100 / num0020)) + "%  平均涨跌幅：" + df.format(v020)+ "%  平均涨幅：" + df.format(vz020)+ "%  平均跌幅：" + df.format(vf020));
            System.out.println(("第二天涨的次数：" + numu2020 + "  跌的次数：" + numd2020 + "  上涨概率： " + df.format((double) numu2020 * 100 / num0020)) + "%  平均涨跌幅：" + df.format(v2020));
            System.out.println("板数：" + ban020);
            System.out.println("中股天数："+dateList020.size());


            double v2050 = 0;
            double vz2050 = 0;
            double vf2050 = 0;
            double v22050 = 0;
            double v32050 = 0;
            double v52050 = 0;
            double v102050 = 0;
            double v202050 = 0;

            if (num02050 != 0 && sum2050 != 0) {
                v2050 = sum2050 / num02050;
                vz2050= sumz2050 / numu2050;
                vf2050= sumf2050 / numd2050;
            }
            if (num02050 != 0 && sum22050 != 0) {
                v22050 = sum22050 / num02050;
            }
            if (num02050 != 0 && sum32050 != 0) {
                v32050 = sum32050 / num02050;
            }


            System.out.println("----------");
            System.out.println("20-50");
            System.out.println(("一天后涨的次数：" + numu2050 + "  跌的次数：" + numd2050 + "  上涨概率： " + df.format((double) numu2050 * 100 / num02050)) + "%  平均涨跌幅：" + df.format(v2050)+ "%  平均涨幅：" + df.format(vz2050)+ "%  平均跌幅：" + df.format(vf2050));
            System.out.println(("2天后涨的次数：" + numu22050 + "  跌的次数：" + numd22050 + "  上涨概率： " + df.format((double) numu22050 * 100 / num02050)) + "%  平均涨幅：" + df.format(v22050));
            System.out.println("板数：" + ban2050);
            System.out.println("中股天数："+dateList2050.size());


            double v50100 = 0;
            double vz50100 = 0;
            double vf50100 = 0;
            double v250100 = 0;
            double v350100 = 0;
            double v550100 = 0;
            double v1050100 = 0;
            double v2050100 = 0;

            if (num050100 != 0 && sum50100 != 0) {
                v50100 = sum50100 / num050100;
                vz50100= sumz50100 / numu50100;
                vf50100= sumf50100 / numd50100;
            }
            if (num050100 != 0 && sum250100 != 0) {
                v250100 = sum250100 / num050100;
            }
            if (num050100 != 0 && sum350100 != 0) {
                v350100 = sum350100 / num050100;
            }


            System.out.println("----------");
            System.out.println("50-100");
            System.out.println(("一天后涨的次数：" + numu50100 + "  跌的次数：" + numd50100 + "  上涨概率： " + df.format((double) numu50100 * 100 / num050100)) + "%  平均涨跌幅：" + df.format(v50100)+ "%  平均涨幅：" + df.format(vz50100)+ "%  平均跌幅：" + df.format(vf50100));
            System.out.println(("2天后涨的次数：" + numu250100 + "  跌的次数：" + numd250100 + "  上涨概率： " + df.format((double) numu250100 * 100 / num050100)) + "%  平均涨幅：" + df.format(v250100));
            System.out.println(("3天后涨的次数：" + numu350100 + "  跌的次数：" + numd350100 + "  上涨概率： " + df.format((double) numu350100 * 100 / num050100)) + "%  平均涨幅：" + df.format(v350100));
           System.out.println("板数：" + ban50100);
            System.out.println("中股天数："+dateList50100.size());

            double v100200 = 0;
            double vz100200 = 0;
            double vf100200 = 0;
            double v2100200 = 0;
            double v3100200 = 0;
            double v5100200 = 0;
            double v10100200 = 0;
            double v20100200 = 0;

            if (num0100200 != 0 && sum100200 != 0) {
                v100200 = sum100200 / num0100200;
                vz100200= sumz100200 / numu100200;
                vf100200= sumf100200 / numd100200;
            }
            if (num0100200 != 0 && sum2100200 != 0) {
                v2100200 = sum3100200 / num0100200;
            }
            if (num0100200 != 0 && sum3100200 != 0) {
                v3100200 = sum3100200 / num0100200;
            }


            System.out.println("----------");
            System.out.println("100-200");
            System.out.println(("一天后涨的次数：" + numu100200 + "  跌的次数：" + numd100200 + "  上涨概率： " + df.format((double) numu100200 * 100 / num0100200)) + "%  平均涨跌幅：" + df.format(v100200)+ "%  平均涨幅：" + df.format(vz100200)+ "%  平均跌幅：" + df.format(vf100200));
            System.out.println(("2天后涨的次数：" + numu2100200 + "  跌的次数：" + numd2100200 + "  上涨概率： " + df.format((double) numu2100200 * 100 / num0100200)) + "%  平均涨幅：" + df.format(v2100200));
            System.out.println(("3天后涨的次数：" + numu3100200 + "  跌的次数：" + numd3100200 + "  上涨概率： " + df.format((double) numu3100200 * 100 / num0100200)) + "%  平均涨幅：" + df.format(v3100200));

            System.out.println("板数：" + ban100200);
            System.out.println("中股天数："+dateList100200.size());

            double v200370 = 0;
            double vz200370 = 0;
            double vf200370 = 0;
            double v2200370 = 0;
            double v3200370 = 0;
            double v5200370 = 0;
            double v10200370 = 0;
            double v20200370 = 0;

            if (num0200370 != 0 && sum200370 != 0) {
                v200370 = sum200370 / num0200370;
                vz200370= sumz200370 / numu200370;
                vf200370= sumf200370 / numd200370;
            }
            if (num0200370 != 0 && sum2200370 != 0) {
                v2200370 = sum2200370 / num0200370;
            }
            if (num0200370 != 0 && sum3200370 != 0) {
                v3200370 = sum3200370 / num0200370;
            }


            System.out.println("----------");
            System.out.println("200-370");
            System.out.println(("一天后涨的次数：" + numu200370 + "  跌的次数：" + numd200370 + "  上涨概率： " + df.format((double) numu200370 * 100 / num0200370)) + "%  平均涨跌幅：" + df.format(v200370)+ "%  平均涨幅：" + df.format(vz200370)+ "%  平均跌幅：" + df.format(vf200370));
            System.out.println(("2天后涨的次数：" + numu2200370 + "  跌的次数：" + numd2200370 + "  上涨概率： " + df.format((double) numu2200370 * 100 / num0200370)) + "%  平均涨幅：" + df.format(v2200370));
            System.out.println(("3天后涨的次数：" + numu3200370 + "  跌的次数：" + numd3200370 + "  上涨概率： " + df.format((double) numu3200370 * 100 / num0200370)) + "%  平均涨幅：" + df.format(v3200370));

            System.out.println("板数：" + ban200370);
            System.out.println("中股天数："+dateList200370.size());
        }

    }

    public static void getData(Stock_Json_Data stockJsonData) throws Exception {
        String jsondata = stockJsonData.getJsondata();
        JSONObject jsonObject = JSONObject.parseObject(jsondata);

        String o = jsonObject.get(stockJsonData.getName()).toString();
        List<Stock_Day_Data> stockDayData = JSONArray.parseArray(o, Stock_Day_Data.class);

        if (stockDayData.size() >  140) {

            for (int i = 2; i < 21; i++) {
                //昨日涨幅
                double v= stockDayData.get(i).getZdf();

                JSONObject lines = getLines(stockDayData, i);
                double f1 = Double.parseDouble(lines.get("f1").toString());
                double te1 = Double.parseDouble(lines.get("te1").toString());
                double tw1 = Double.parseDouble(lines.get("tw1").toString());
                double th1 = Double.parseDouble(lines.get("th1").toString());
                double six1 = Double.parseDouble(lines.get("six1").toString());

                JSONObject lines2 = getLines(stockDayData, i+1);
                double f2 = Double.parseDouble(lines2.get("f1").toString());
                double te2 = Double.parseDouble(lines2.get("te1").toString());
                double tw2 = Double.parseDouble(lines2.get("tw1").toString());
                double th2 = Double.parseDouble(lines2.get("th1").toString());
                double six2 = Double.parseDouble(lines2.get("six1").toString());

                //开盘价
                double k= stockDayData.get(i).getK();
                //收盘价
                double s= stockDayData.get(i).getS();
                //最高价
                double g= stockDayData.get(i).getG();
                //最低价
                double d= stockDayData.get(i).getD();

                boolean bf = d < f1 && s > f1;
                boolean bte = d < te1 && s > te1;
                boolean btw = d < tw1 && s > tw1;
                boolean bth = d < th1 && s > th1;
                boolean bsix = d < six1 && s > six1;

                String word = "";
                int flag = 0;
                if (bf) {
                    word = word.concat("上穿五日线");
                    flag++;
                }
                if (bte) {
                    word = word.concat("上穿10日线");
                    flag++;
                }
                if (btw) {
                    word = word.concat("上穿20日线");
                    flag++;
                }
                if (bth) {
                    word = word.concat("上穿30日线");
                    flag++;
                }
                if (bsix) {
                    word = word.concat("上穿60日线");
                    flag++;
                }
                //收盘与最高差距
                double v0000 = (g - s) * 100 / k;
                boolean price8010 = getPrice8010(stockDayData, i);
                boolean price12010 = getPrice12010(stockDayData, i);
                boolean price2010 = getPrice2010(stockDayData, i);
                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1= stockDayData.get(i+1).getMoney();
                double m4 = m0 / m1;
                //实体部分
                double v0 = (s - k) * 100 / k;
                //if(/*s==g&& */v < 9.8 && v > -9.8){
                boolean b1 = (f1 - te1) > (f2 - te2);
                boolean b = f1 > te1 && te1 > tw1 && tw1 > th1 && th1 > six1 && f1 > s && s > k&&f2>te2;
                if (/*v0000 < 0.2&&*/ v < 9.8 && v > -9.8&&flag>2&&flag<4/*&&price12010&&m4>2*//*&&price8010*//*&&m4>2&&v0>3*/) {
                    //次日涨幅
                    double v11= stockDayData.get(i-1).getZdf();
                    //第二日涨幅
                    double v12= stockDayData.get(i-2).getZdf();
                    if (v11 > 0 || v11 == 0) {
                        numu020++;
                        sumz020+=v11;
                    } else {
                        sumf020+=v11;
                        numd020++;
                    }
                    if (v12 > 0 || v12 == 0) {
                        numu2020++;
                    } else {
                        numd2020++;
                    }

                    sum020 += v11;
                    sum2020 += v12;
                    num0020++;
                    if (!dateList020.contains(stockDayData.get(i).getGetdate())) {
                        dateList020.add(stockDayData.get(i).getGetdate());
                    }
                    if (v11 > 9.8) {
                        ban020++;
                    }
                    System.out.println(stockDayData.get(i).getName() + " : " + stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11+ "   第二日涨幅" + v12);
                }
            }
        }

        if (stockDayData.size() >  170) {
            for (int i = 21; i < 50; i++) {
                //昨日涨幅
                double v= stockDayData.get(i).getZdf();

                JSONObject lines = getLines(stockDayData, i);
                double f1 = Double.parseDouble(lines.get("f1").toString());
                double te1 = Double.parseDouble(lines.get("te1").toString());
                double tw1 = Double.parseDouble(lines.get("tw1").toString());
                double th1 = Double.parseDouble(lines.get("th1").toString());
                double six1 = Double.parseDouble(lines.get("six1").toString());
                JSONObject lines2 = getLines(stockDayData, i+1);
                double f2 = Double.parseDouble(lines2.get("f1").toString());
                double te2 = Double.parseDouble(lines2.get("te1").toString());
                double tw2 = Double.parseDouble(lines2.get("tw1").toString());
                double th2 = Double.parseDouble(lines2.get("th1").toString());
                double six2 = Double.parseDouble(lines2.get("six1").toString());
                //开盘价
                double k= stockDayData.get(i).getK();
                //收盘价
                double s= stockDayData.get(i).getS();
                //最高价
                double g= stockDayData.get(i).getG();
                //最低价
                double d= stockDayData.get(i).getD();

                boolean bf = d < f1 && s > f1;
                boolean bte = d < te1 && s > te1;
                boolean btw = d < tw1 && s > tw1;
                boolean bth = d < th1 && s > th1;
                boolean bsix = d < six1 && s > six1;
                String word = "";
                int flag = 0;
                if (bf) {
                    word = word.concat("上穿五日线");
                    flag++;
                }
                if (bte) {
                    word = word.concat("上穿10日线");
                    flag++;
                }
                if (btw) {
                    word = word.concat("上穿20日线");
                    flag++;
                }
                if (bth) {
                    word = word.concat("上穿30日线");
                    flag++;
                }
                if (bsix) {
                    word = word.concat("上穿60日线");
                    flag++;
                }

                //收盘与最高差距
                double v0000 = (g - s) * 100 / k;
                boolean price8010 = getPrice8010(stockDayData, i);
                boolean price12010 = getPrice12010(stockDayData, i);
                boolean price2010 = getPrice2010(stockDayData, i);
                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1= stockDayData.get(i+1).getMoney();
                double m4 = m0 / m1;
                //实体部分
                double v0 = (s - k) * 100 / k;
                //if(/*s==g&& */v < 9.8 && v > -9.8){
                boolean b1 = (f1 - te1) > (f2 - te2);
                boolean b = f1 > te1 && te1 > tw1 && tw1 > th1 && th1 > six1 && f1 > s && s > k&&f2>te2;
                if (/*v0000 < 0.2&&*/ v < 9.8 && v > -9.8&&flag>2&&flag<4/*&&price12010&&m4>2*//*&&price8010*//*&&m4>2&&v0>3*/) {

                    //第3天收盘价
                    double s03 = stockDayData.get(i-3).getS();
                    double v3 = (s03 - s)*100 / s;

                    //次日涨幅
                    double v11= stockDayData.get(i-1).getZdf();
                    //第二天涨幅
                    double v12= stockDayData.get(i-2).getZdf();

                    if (v11 > 0 || v11 == 0) {
                        numu2050++;
                        sumz2050+=v11;
                    } else {
                        sumf2050+=v11;
                        numd2050++;
                    }
                    if(v12>0||v12==0){
                        numu22050++;
                    }else {
                        numd22050++;
                    }
                    sum2050 += v11;
                    sum22050 += v12;
                    sum32050 += v3;


                    num02050++;

                    if (s03 > s) {
                        numu32050++;
                    } else {
                        numd32050++;
                    }


                      /*  String date = stockDayData.get(i).getGetdate();
                        if(date.startsWith("2023")){
                            System.out.println(date);
                        }*/
                    if (!dateList2050.contains(stockDayData.get(i).getGetdate())) {
                        dateList2050.add(stockDayData.get(i).getGetdate());
                    }
                    if (v11 > 9.8) {
                        ban2050++;
                    }

                    System.out.println(stockDayData.get(i).getName() + " : " + stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11+ "   第二日涨幅" + v12 + "   3日涨幅" + df.format(v3));
                }
            }
        }

        if (stockDayData.size() >  220) {
            for (int i = 50; i < 100; i++) {
                //昨日涨幅
                double v= stockDayData.get(i).getZdf();

                JSONObject lines = getLines(stockDayData, i);
                double f1 = Double.parseDouble(lines.get("f1").toString());
                double te1 = Double.parseDouble(lines.get("te1").toString());
                double tw1 = Double.parseDouble(lines.get("tw1").toString());
                double th1 = Double.parseDouble(lines.get("th1").toString());
                double six1 = Double.parseDouble(lines.get("six1").toString());
                JSONObject lines2 = getLines(stockDayData, i+1);
                double f2 = Double.parseDouble(lines2.get("f1").toString());
                double te2 = Double.parseDouble(lines2.get("te1").toString());
                double tw2 = Double.parseDouble(lines2.get("tw1").toString());
                double th2 = Double.parseDouble(lines2.get("th1").toString());
                double six2 = Double.parseDouble(lines2.get("six1").toString());
                //开盘价
                double k= stockDayData.get(i).getK();
                //收盘价
                double s= stockDayData.get(i).getS();
                //最高价
                double g= stockDayData.get(i).getG();
                //最低价
                double d= stockDayData.get(i).getD();
                boolean bf = d < f1 && s > f1;
                boolean bte = d < te1 && s > te1;
                boolean btw = d < tw1 && s > tw1;
                boolean bth = d < th1 && s > th1;
                boolean bsix = d < six1 && s > six1;
                String word = "";
                int flag = 0;
                if (bf) {
                    word = word.concat("上穿五日线");
                    flag++;
                }
                if (bte) {
                    word = word.concat("上穿10日线");
                    flag++;
                }
                if (btw) {
                    word = word.concat("上穿20日线");
                    flag++;
                }
                if (bth) {
                    word = word.concat("上穿30日线");
                    flag++;
                }
                if (bsix) {
                    word = word.concat("上穿60日线");
                    flag++;
                }
                //收盘与最高差距
                double v0000 = (g - s) * 100 / k;
                boolean price8010 = getPrice8010(stockDayData, i);
                boolean price12010 = getPrice12010(stockDayData, i);
                boolean price2010 = getPrice2010(stockDayData, i);
                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1= stockDayData.get(i+1).getMoney();
                double m4 = m0 / m1;
                //实体部分
                double v0 = (s - k) * 100 / k;
                //if(/*s==g&& */v < 9.8 && v > -9.8){
                boolean b1 = (f1 - te1) > (f2 - te2);
                boolean b = f1 > te1 && te1 > tw1 && tw1 > th1 && th1 > six1 && f1 > s && s > k&&f2>te2;
                if (/*v0000 < 0.2&&*/ v < 9.8 && v > -9.8&&flag>2&&flag<4/*&&price12010&&m4>2*//*&&price8010*//*&&m4>2&&v0>3*/) {
                    //第3天收盘价
                    double s03 = stockDayData.get(i-3).getS();
                    double v3 = (s03 - s)*100 / s;


                    //次日涨幅
                    double v11= stockDayData.get(i-1).getZdf();
                    //第二天涨幅
                    double v12= stockDayData.get(i-2).getZdf();

                    if (v11 > 0 || v11 == 0) {
                        numu50100++;
                        sumz50100+=v11;
                    } else {
                        sumf50100+=v11;
                        numd50100++;
                    }
                    if(v12>0||v12==0){
                        numu250100++;
                    }else {
                        numd250100++;
                    }

                    sum50100 += v11;
                    sum250100 += v12;
                    sum350100 += v3;


                    num050100++;

                    if (s03 > s) {
                        numu350100++;
                    } else {
                        numd350100++;
                    }


                      /*  String date = stockDayData.get(i).getGetdate();
                        if(date.startsWith("2023")){
                            System.out.println(date);
                        }*/
                    if (!dateList50100.contains(stockDayData.get(i).getGetdate())) {
                        dateList50100.add(stockDayData.get(i).getGetdate());
                    }
                    if (v11 > 9.8) {
                        ban50100++;
                    }

                    System.out.println(stockDayData.get(i).getName() + " : " + stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11+ "   第二日涨幅" + v12 + "   3日涨幅" + df.format(v3));
                }
            }
        }

        if (stockDayData.size() >  320) {
            for (int i = 100; i < 200; i++) {
                //昨日涨幅
                double v= stockDayData.get(i).getZdf();

                JSONObject lines = getLines(stockDayData, i);
                double f1 = Double.parseDouble(lines.get("f1").toString());
                double te1 = Double.parseDouble(lines.get("te1").toString());
                double tw1 = Double.parseDouble(lines.get("tw1").toString());
                double th1 = Double.parseDouble(lines.get("th1").toString());
                double six1 = Double.parseDouble(lines.get("six1").toString());
                JSONObject lines2 = getLines(stockDayData, i+1);
                double f2 = Double.parseDouble(lines2.get("f1").toString());
                double te2 = Double.parseDouble(lines2.get("te1").toString());
                double tw2 = Double.parseDouble(lines2.get("tw1").toString());
                double th2 = Double.parseDouble(lines2.get("th1").toString());
                double six2 = Double.parseDouble(lines2.get("six1").toString());
                //开盘价
                double k= stockDayData.get(i).getK();

                //收盘价
                double s= stockDayData.get(i).getS();

                //最高价
                double g= stockDayData.get(i).getG();
                //最低价
                double d= stockDayData.get(i).getD();

                //收盘价
                double s1= stockDayData.get(i+1).getS();
                double k5= stockDayData.get(i+5).getK();




                boolean bf = d < f1 && s > f1;
                boolean bte = d < te1 && s > te1;
                boolean btw = d < tw1 && s > tw1;
                boolean bth = d < th1 && s > th1;
                boolean bsix = d < six1 && s > six1;
                String word = "";
                int flag = 0;
                if (bf) {
                    word = word.concat("上穿五日线");
                    flag++;
                }
                if (bte) {
                    word = word.concat("上穿10日线");
                    flag++;
                }
                if (btw) {
                    word = word.concat("上穿20日线");
                    flag++;
                }
                if (bth) {
                    word = word.concat("上穿30日线");
                    flag++;
                }
                if (bsix) {
                    word = word.concat("上穿60日线");
                    flag++;
                }

                //收盘与最高差距
                double v0000 = (g - s) * 100 / k;
                boolean price8010 = getPrice8010(stockDayData, i);
                boolean price12010 = getPrice12010(stockDayData, i);
                boolean price2010 = getPrice2010(stockDayData, i);
                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1= stockDayData.get(i+1).getMoney();
                double m4 = m0 / m1;
                //实体部分
                double v0 = (s - k) * 100 / k;
                //if(/*s==g&& */v < 9.8 && v > -9.8){
                boolean b1 = (f1 - te1) > (f2 - te2);
                boolean b = f1 > te1 && te1 > tw1 && tw1 > th1 && th1 > six1 && f1 > s && s > k&&f2>te2;
                if (/*v0000 < 0.2&&*/ v < 9.8 && v > -9.8&&flag>2&&flag<4/*&&price12010&&m4>2*//*&&price8010*//*&&m4>2&&v0>3*/) {
                    double s03 = stockDayData.get(i-3).getS();
                    double v3 = (s03 - s)*100 / s;


                    //次日涨幅
                    double v11= stockDayData.get(i-1).getZdf();
                    //第二天涨幅
                    double v12= stockDayData.get(i-2).getZdf();
                    if (v11 > 0 || v11 == 0) {
                        numu100200++;
                        sumz50100+=v11;
                    } else {
                        sumf100200+=v11;
                        numd100200++;
                    }

                    if(v12>0||v12==0){
                        numu2100200++;
                    }else {
                        numd2100200++;
                    }


                    sum100200 += v12;
                    sum2100200 += v11;
                    sum3100200 += v3;


                    num0100200++;

                    if (s03 > s) {
                        numu3100200++;
                    } else {
                        numd3100200++;
                    }


                      /*  String date = stockDayData.get(i).getGetdate();
                        if(date.startsWith("2023")){
                            System.out.println(date);
                        }*/
                    if (!dateList100200.contains(stockDayData.get(i).getGetdate())) {
                        dateList100200.add(stockDayData.get(i).getGetdate());
                    }
                    if (v11 > 9.8) {
                        ban2050++;
                    }

                    System.out.println(stockDayData.get(i).getName() + " : " + stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11+ "   第二日涨幅" + v12 + "   3日涨幅" + df.format(v3));
                }
            }
        }

        if (stockDayData.size() >  490) {
            for (int i = 200; i < 370; i++) {
                //昨日涨幅
                double v= stockDayData.get(i).getZdf();
                JSONObject lines = getLines(stockDayData, i);
                double f1 = Double.parseDouble(lines.get("f1").toString());
                double te1 = Double.parseDouble(lines.get("te1").toString());
                double tw1 = Double.parseDouble(lines.get("tw1").toString());
                double th1 = Double.parseDouble(lines.get("th1").toString());
                double six1 = Double.parseDouble(lines.get("six1").toString());
                JSONObject lines2 = getLines(stockDayData, i+1);
                double f2 = Double.parseDouble(lines2.get("f1").toString());
                double te2 = Double.parseDouble(lines2.get("te1").toString());
                double tw2 = Double.parseDouble(lines2.get("tw1").toString());
                double th2 = Double.parseDouble(lines2.get("th1").toString());
                double six2 = Double.parseDouble(lines2.get("six1").toString());
                //开盘价
                double k= stockDayData.get(i).getK();
                //收盘价
                double s= stockDayData.get(i).getS();
                //最高价
                double g= stockDayData.get(i).getG();
                //最低价
                double d= stockDayData.get(i).getD();



                boolean bf = d < f1 && s > f1;
                boolean bte = d < te1 && s > te1;
                boolean btw = d < tw1 && s > tw1;
                boolean bth = d < th1 && s > th1;
                boolean bsix = d < six1 && s > six1;
                String word = "";
                int flag = 0;
                if (bf) {
                    word = word.concat("上穿五日线");
                    flag++;
                }
                if (bte) {
                    word = word.concat("上穿10日线");
                    flag++;
                }
                if (btw) {
                    word = word.concat("上穿20日线");
                    flag++;
                }
                if (bth) {
                    word = word.concat("上穿30日线");
                    flag++;
                }
                if (bsix) {
                    word = word.concat("上穿60日线");
                    flag++;
                }

                //收盘与最高差距
                double v0000 = (g - s) * 100 / k;
                boolean price8010 = getPrice8010(stockDayData, i);
                boolean price12010 = getPrice12010(stockDayData, i);
                boolean price2010 = getPrice2010(stockDayData, i);
                //今日成交额
                double m0 = stockDayData.get(i).getMoney();
                //昨日成交额
                double m1= stockDayData.get(i+1).getMoney();
                double m4 = m0 / m1;
                //实体部分
                double v0 = (s - k) * 100 / k;
                //if(/*s==g&& */v < 9.8 && v > -9.8){
                boolean b1 = (f1 - te1) > (f2 - te2);
                boolean b = f1 > te1 && te1 > tw1 && tw1 > th1 && th1 > six1 && f1 > s && s > k&&f2>te2;
                //if (/*v0000 < 0.2&&*/ b1&&b&&v < 9.8 && v > -9.8/*&&flag>2*//*&&price12010&&m4>2*//*&&price8010*//*&&m4>2&&v0>3*/) {
                if (/*v0000 < 0.2&&*/ v < 9.8 && v > -9.8&&flag>2&&flag<4/*&&price12010&&m4>2*//*&&price8010*//*&&m4>2&&v0>3*/) {
                    double s03 = stockDayData.get(i-3).getS();
                    double v3 = (s03 - s)*100 / s;


                    //次日涨幅
                    double v11= stockDayData.get(i-1).getZdf();
                    //第二天涨幅
                    double v12= stockDayData.get(i-2).getZdf();
                    if (v11 > 0 || v11 == 0) {
                        numu200370++;
                        sumz200370+=v11;
                    } else {
                        sumf200370+=v11;
                        numd200370++;
                    }

                    if(v12>0||v12==0){
                        numu2200370++;
                    }else {
                        numd2200370++;
                    }
                    sum200370 += v12;
                    sum2200370 += v11;
                    sum3200370 += v3;


                    num0200370++;

                    if (s03 > s) {
                        numu3200370++;
                    } else {
                        numd3200370++;
                    }

                      /*  String date = stockDayData.get(i).getGetdate();
                        if(date.startsWith("2023")){
                            System.out.println(date);
                        }*/
                    if (!dateList200370.contains(stockDayData.get(i).getGetdate())) {
                        dateList200370.add(stockDayData.get(i).getGetdate());
                    }
                    if (v11 > 9.8) {
                        ban200370++;
                    }

                    System.out.println(stockDayData.get(i).getName() + " : " + stockDayData.get(i).getGetdate() + "  当日涨幅" + v + "   次日涨幅" + v11+ "   第二日涨幅" + v12 + "   3日涨幅" + df.format(v3));
                }
            }
        }
    }

    //获取所有均线
    public static JSONObject getLines(List<Stock_Day_Data> stockDayData, int startDay) {
        //日线
        double totalsix1 = 0.0;
        double totalth1 = 0.0;
        double totaltw1 = 0.0;
        double totalte1 = 0.0;
        double totalf1 = 0.0;
        for (int j = 0; j < 60; j++) {
            double price = stockDayData.get(startDay + j).getS();

            if (j < 5) {
                totalf1 += price;
            }
            if (j < 10) {
                totalte1 += price;
            }
            if (j < 20) {
                totaltw1 += price;

            }
            if (j < 30) {
                totalth1 += price;

            }
            totalsix1 += price;

        }
        double six1 = totalsix1 / 60;
        double th1 = totalth1 / 30;
        double tw1 = totaltw1 / 20;
        double te1 = totalte1 / 10;
        double f1 = totalf1 / 5;
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("f1", f1);
        jsonObject.put("te1", te1);
        jsonObject.put("tw1", tw1);
        jsonObject.put("th1", th1);
        jsonObject.put("six1", six1);
        return jsonObject;

    }

    //近120天 价格处于低位
    public static boolean getPrice(List<Stock_Day_Data> stockDayData, int startDay) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < 10; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 < prices.get(2)/*s1==prices.get(0)*/;
    }
    //近120天 价格处于低位
    public static boolean getPriceincre(List<Stock_Day_Data> stockDayData, int startDay,int high,int low) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < high; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 > prices.get(low)/*s1==prices.get(0)*/;
    }

    //近120天 价格处于低位
    public static boolean getPriceredu(List<Stock_Day_Data> stockDayData, int startDay,int high,int low) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < high; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 < prices.get(low)/*s1==prices.get(0)*/;
    }
    //近120天 价格处于低位
    public static boolean getPrice12010(List<Stock_Day_Data> stockDayData, int startDay) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < 120; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 < prices.get(10)/*s1==prices.get(0)*/;
    }
    //近120天 价格处于低位
    public static boolean getPrice2010(List<Stock_Day_Data> stockDayData, int startDay) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < 20; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 > prices.get(10)/*s1==prices.get(0)*/;
    }
    //近120天 价格处于低位
    public static boolean getPrice8010(List<Stock_Day_Data> stockDayData, int startDay) {
        //最近120天内收盘价集合
        List<Double> prices = new ArrayList<>();
        double s1 = stockDayData.get(startDay + 1).getS();
        double s2 = stockDayData.get(startDay).getS();
        for (int j = 0; j < 80; j++) {
            //收盘价
            double p2 = stockDayData.get(startDay + j).getS();
            prices.add(p2);
        }
        // 使用List的sort()方法和Lambda表达式进行排序
        prices.sort(Double::compare);
        return s2 < prices.get(10)/*s1==prices.get(0)*/;
    }
}

